package com.android.lovely.data

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

/**
 *
 * @author why
 * @date 2025/3/15 20:24
 */
@JsonClass(generateAdapter = true)
data class ImageGenerateData(
    @Json(name = "cost") val price: Int = 0,
    @Json(name = "model_list") val modelCollections: ModelList,
    @Json(name = "param_list") val parameterCollections: ParamList
)

@JsonClass(generateAdapter = true)
data class ModelList(
    @Json(name = "real") val realistic: List<GeneratedModel> = listOf(),
    @Json(name = "cartoon") val animated: List<GeneratedModel> = listOf()
)

@JsonClass(generateAdapter = true)
data class ParamList(
    @Json(name = "nsfw_on") val nsfwEnabled: List<CreateImageDetail> = listOf(),
    @Json(name = "nsfw_off") val nsfwDisabled: List<CreateImageDetail> = listOf(),
    @Json(name = "param_list") val parameterDetails: List<CreateImageDetail> = listOf(),
)

@JsonClass(generateAdapter = true)
data class GeneratedModel(
    @Json(name = "name") val label: String = "",
    @Json(name = "image") val thumbnail: String = "",
    @Json(name = "value") val content: String = "",
    @Json(name = "status") val state: Int = 0,
    @Json(name = "weight") val priority: String = "",
    @Json(name = "style_list") val styleVariations: List<GeneratedModel> = listOf()
) {
    @Json(ignore = false)
    var isSelected: Boolean = false
}


@JsonClass(generateAdapter = true)
data class CreateImageDetail(
    @Json(name = "id") val identifier: Int = 0,
    @Json(name = "code") val codeValue: String = "",
    @Json(name = "name_en") val title: String = "",
    @Json(name = "type") val categoryType: Int = 0,
    @Json(name = "status") val state: Int = 0,
    @Json(name = "is_mul") val multipleSelection: Int = 0,
    @Json(name = "is_require") val required: Int = 0,
    @Json(name = "max_selected") val maxOptions: Int = 0,
    @Json(name = "value") val contentList: List<ParameterValue> = listOf(),
    @Json(name = "nsfw_on") val nsfwEnabledValues: List<ParameterValue> = listOf(),
    @Json(name = "nsfw_off") val nsfwDisabledValues: List<ParameterValue> = listOf(),
) {
    @Json(ignore = true)
    var isExpand = true

    @Json(ignore = true)
    var nsfwEnabled = false

    @Json(ignore = true)
    var selectedValue: MutableList<ParameterValue> = mutableListOf()

    fun reset() {
        nsfwEnabledValues.forEach { it.isSelected = false }
        nsfwDisabledValues.forEach { it.isSelected = false }
        contentList.forEach { it.isSelected = false }
    }
}

@JsonClass(generateAdapter = true)
data class ParameterValue(
    @Json(name = "name_en") val title: String = "",
    @Json(name = "prompt") val description: String = "",
) {
    @Json(ignore = true)
    var isSelected: Boolean = false
}